from django.db import models

# Create your models here.
from django.db.models import CASCADE
from ckeditor_uploader.fields import RichTextUploadingField
class QingHuiType(models.Model):
    choice_statues = ((1, '显示'), (0, '隐藏'))
    type_statues = models.IntegerField(default=0, blank=False, choices=choice_statues)
    typeid = models.AutoField(primary_key=True)
    buttonname = models.CharField(max_length=20,default='免费领取淘宝机器人', blank=False,null=False)
    step1 = models.CharField(max_length=20,default='点击右方按钮', blank=False,null=False)
    step2 = models.CharField(max_length=20,default='发送“111', blank=False,null=False)
    step3 = models.CharField(max_length=20,default='获得奖励', blank=False,null=False)
    titleGonggao = models.CharField(max_length=50,default='福利提醒：赠送您一款淘宝省钱工具，只需要点击下方的蓝色按钮就可以领取', blank=False,null=False)

    def __str__(self):
        return f'{self.buttonname}按钮名字'
    class Meta:
        verbose_name = '清灰工具小广告内容'
        verbose_name_plural = verbose_name



class Type(models.Model):
    choice_statues = ((1, '显示'), (0, '隐藏'))
    type_statues = models.IntegerField(default=0, blank=False, choices=choice_statues)
    typeid = models.AutoField(primary_key=True)
    typename = models.CharField(max_length=10,default='百度VIP', blank=False,null=False)
    typeIMG = models.ImageField(upload_to='scoreimgs/%Y/%m/%d', default=None, blank=True, null=True)
    typeweight = models.IntegerField(default=1, blank=False, null=False)  # 禁止留空(类型权重)
    def __str__(self):
        return f'{self.typename}类型，权重为{self.typeweight}'
    class Meta:
        verbose_name = '分类表'
        verbose_name_plural = verbose_name
class Score(models.Model):
    fenxiangid = models.AutoField(verbose_name='商品ID',primary_key=True)
    fenxiangname = models.CharField(verbose_name='分享标题',max_length=100,default='分享内容', blank=False,null=False)   #禁止空
    fenxiangIMG = models.ImageField(upload_to='scoreimgs/%Y/%m/%d', default='scoreimgs/bg/default.jpg', blank=True, null=True) #允许空
    score_type = models.ForeignKey('Type',related_name='scoretype',default=None,blank=False,on_delete=CASCADE) #blank =false 表单必须填写内容
    fenxiangusername = models.CharField(verbose_name='分享账号',max_length=100, default='分享账号用户名',blank=False,null=False) #禁止空
    fenxiangpassword = models.CharField(verbose_name='分享密码',max_length=100, default='分享账号密码',blank=False,null=False) #禁止空
    fenxiangusername_button = models.CharField(verbose_name='账号按钮',max_length=100, default='复制账号',blank=False,null=False) #禁止空
    fenxiangpassword_button = models.CharField(verbose_name='密码按钮',max_length=100, default='显示密码',blank=False,null=False) #禁止空
    scoreNeed = models.IntegerField(verbose_name='查看所需积分',default=5,blank=True,null=False) #禁止留空
    word = models.CharField(max_length=200, default='这个账号仍然有效',blank=False, null=True) #禁止空
    redword = models.CharField(max_length=200, default='分享才能获得积分',blank=False, null=True) #禁止空  null=True, 表示数据库的该字段可以为空
    choice_statues = ((1, '上架'), (0, '下架'))
    statues = models.IntegerField(verbose_name='商品状态',default=0,blank=False,choices=choice_statues) #禁止留空
    fenxiangdata = models.DateTimeField(auto_now_add=True)
    itemweight = models.IntegerField(verbose_name='展示权重',default=1,blank=False,null=False) #禁止留空(权重)
    choiceOnIndex = ((1, '显示'), (0, '不显示'))
    ifShowIndex = models.IntegerField(verbose_name='首页推荐',default=0,blank=False,choices=choiceOnIndex)
    clickNum = models.IntegerField(verbose_name='查看人数',default=0,blank=False,null=False)
    def __str__(self):
        return f'id:[{self.fenxiangid}],{self.score_type.typename}类型的账号：{self.fenxiangname}，权重为：{self.itemweight}'
    class Meta:
        verbose_name = '账号表'
        verbose_name_plural = verbose_name
        ordering = ['-itemweight','-fenxiangid']


class IndexInfo(models.Model):
    GongGao = models.TextField(max_length=3000,default='',null=True,blank=True)


# 问题标题和答案（7种答案）存储


class Questions(models.Model):
    choice_statues = ((1, '显示'), (0, '隐藏'))
    id = models.AutoField(verbose_name='题目答案ID',primary_key=True)
    title = models.CharField(verbose_name='题目标题',max_length=300, default='',blank=False,null=False) #禁止空
    key1 = models.CharField(verbose_name='A优评价',max_length=300, default='',blank=False,null=False) #禁止空
    key2 = models.CharField(verbose_name='B优评价',max_length=300, default='',blank=False,null=False) #禁止空
    key3 = models.CharField(verbose_name='C优评价',max_length=300, default='',blank=False,null=False) #禁止空
    key4 = models.CharField(verbose_name='AB优评价',max_length=300, default='',blank=False,null=False) #禁止空
    key5 = models.CharField(verbose_name='AC优评价',max_length=300, default='',blank=False,null=False) #禁止空
    key6 = models.CharField(verbose_name='BC优评价',max_length=300, default='',blank=False,null=False) #禁止空
    key7 = models.CharField(verbose_name='均衡评价',max_length=300, default='',blank=False,null=False) #禁止空
    type_statues = models.IntegerField(default=0, blank=False, choices=choice_statues)

    class Meta:
        verbose_name = '(答题小程序)标题和结果'
        verbose_name_plural = verbose_name
        ordering = ['id']


# 题目问题内容存储
class QItem(models.Model):
    id = models.AutoField(verbose_name='题目答案ID',primary_key=True)# 题目存储
    qItem_questions = models.ForeignKey('Questions',related_name='qItem_questions0',default=None,blank=False,on_delete=CASCADE)
    question = models.CharField(verbose_name='问题内容',max_length=300, default='',blank=False,null=False) #禁止空
    A = models.CharField(verbose_name='A选项',max_length=300, default='',blank=False,null=False) #禁止空
    B = models.CharField(verbose_name='B选项',max_length=300, default='',blank=False,null=False) #禁止空
    C = models.CharField(verbose_name='C选项',max_length=300, default='',blank=False,null=False) #禁止空

    class Meta:
        verbose_name = '(答题小程序)问题'
        verbose_name_plural = verbose_name
        ordering = ['id',]


# 随机返回假的用户名和头像
class RandomUserInfo(models.Model):
    id = models.AutoField(verbose_name='随机用户信息',primary_key=True)# 随机产生用户信息，名字和头像
    userName = models.CharField(verbose_name='问题内容',max_length=300, default='',blank=False,null=False) #禁止空
    user_img = models.ImageField(upload_to='scoreimgs/file/', default='scoreimgs/file/default.jpg', blank=True, null=True) #允许空

    class Meta:
        verbose_name = '(通用API)随机返回假的用户名和头像'
        verbose_name_plural = verbose_name
        ordering = ['id']